package com.huamao.niceman.scrollviewpager.home.present;

import com.huamao.niceman.scrollviewpager.base.BasePresent;
import com.huamao.niceman.scrollviewpager.model.DayModel;
import com.huamao.niceman.scrollviewpager.utils.FragmentInterface;
import com.huamao.niceman.scrollviewpager.utils.RetrofitSingleton;
import com.huamao.niceman.scrollviewpager.utils.ServiceApi;

import java.util.HashMap;
import java.util.Map;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

/**
 * Created by LuanXianSheng on 2017/6/13.
 */

public class ConstellationPresent extends BasePresent<FragmentInterface> {
    private FragmentInterface mView ;
    public  ConstellationPresent(FragmentInterface fragmentInterface){
        mView = fragmentInterface  ;
    }

    /**
     * 网络请求数据
     */
    public  void getInternetData(String name,String type){
        Map<String,String> map = new HashMap<>() ;
        map.put("key","0da483a1854bd6e32a8890785ca24a63");
        map.put("consName",name);
        map.put("type",type);
        ServiceApi.XingZuo xingzuo = RetrofitSingleton.newInstance().create(ServiceApi.XingZuo.class) ;
        Call<DayModel> day = xingzuo.getDay(map) ;
        day.enqueue(new Callback<DayModel>() {
            @Override
            public void onResponse(Call<DayModel> call, Response<DayModel> response) {
                DayModel bean = response.body() ;
                if (bean != null){
                    mView.getData(bean);
                }
            }

            @Override
            public void onFailure(Call<DayModel> call, Throwable t) {

            }
        });
    }
}
